#Script para generar tomogramas 

for dat in `ls /home/beren/datasets/*.sdf`
do
	minum=11.5
	inicio=12
	cd /usr/local/doppler
	sudo ./makimg NSIDE=400 NIMAGE=1 IMAGE=script.sdf VPIX= 18 NWAVE=1 WAVE=6562.76 FWHM=32 GAMMA=7.64 NSUB=1 OFFSET=0 		NDIV=5 USE='PHASES' FANCY=FALSE CONST=1
	echo "paso el makimg"	
	echo $dat
	data=${dat##*sets/}
	echo $data
	sudo ./optscl IMAGE=script DATA=$dat 
	sudo ./memit IMAGE=script DATA=/home/beren/datasets/$data CAIM=$inicio NITS=5 RMAX=0.2 NDEF=1
	for (( i = 1; i <= 18; i++ ))
	do
		cd /usr/local/doppler
		echo "Mi numero es $minum, lo puedes ver?"
		data=${dat##*sets/}
		echo $data
		dir=/home/beren/datasets/$data
		sudo ./memit IMAGE=script DATA=$dir CAIM=$minum NITS=2 RMAX=0.2 NDEF=1
		echo "paso el memit"
		minum=$(echo 'scale=3;'$minum'-0.5' | bc -l)
		sudo cp /usr/local/doppler/script.sdf /home/beren/test_$i$data
		dato=$data
		data=${data:0:${#data}-4}
		cd /star-hawaiki/bin/convert/
		./ndf2tiff /home/beren/test_$i$dato /home/beren/test_$i$data
		cd /usr/bin/
		./convert /home/beren/test_$i$data.tif /home/beren/ttest_$i$data.png
		cd /home/beren/
		sudo rm test_$i$data.tif
		sudo rm /home/beren/test_$i$dato
	done
done
